local ChooseHeroCell = class("ChooseHeroCell")

local MAX_CELL = 5

function ChooseHeroCell:ctor()
end
function ChooseHeroCell:start()
    for i = 1, MAX_CELL do
        self["_icon" .. i]:setCallback(handler(self, self._onCardClick))
    end
end

function ChooseHeroCell:updateUI(lines, selectedId)
    for i = 1, MAX_CELL do
        local data = lines[i]
        if data then
            self["_icon" .. i].gameObject:SetActive(true)
            self["_icon" .. i]:updateUI(data)
            self["_icon" .. i]:setCheck(data:getId() == selectedId)
        else
            self["_icon" .. i].gameObject:SetActive(false)
        end
    end
end

function ChooseHeroCell:_onCardClick(heroId)
    if self.customCallback then
        self.customCallback(heroId)
    end
end

return ChooseHeroCell
